<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>清除浏览器缓存 - 京东商城</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }
        
        .container {
            background: white;
            border-radius: 20px;
            padding: 40px;
            max-width: 600px;
            width: 100%;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
        }
        
        h1 {
            text-align: center;
            color: #333;
            margin-bottom: 30px;
            font-size: 28px;
        }
        
        .status {
            padding: 20px;
            border-radius: 10px;
            margin-bottom: 20px;
            text-align: center;
            font-size: 16px;
        }
        
        .info {
            background: #e3f2fd;
            color: #1976d2;
            border: 2px solid #1976d2;
        }
        
        .success {
            background: #e8f5e9;
            color: #2e7d32;
            border: 2px solid #2e7d32;
        }
        
        .warning {
            background: #fff3e0;
            color: #e65100;
            border: 2px solid #e65100;
        }
        
        .btn {
            width: 100%;
            padding: 15px;
            border: none;
            border-radius: 10px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s;
            margin-bottom: 10px;
            font-weight: bold;
        }
        
        .btn-primary {
            background: #e4393c;
            color: white;
        }
        
        .btn-primary:hover {
            background: #c81623;
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(232, 57, 60, 0.4);
        }
        
        .btn-secondary {
            background: #667eea;
            color: white;
        }
        
        .btn-secondary:hover {
            background: #5568d3;
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
        }
        
        .info-box {
            background: #f5f5f5;
            padding: 20px;
            border-radius: 10px;
            margin-bottom: 20px;
        }
        
        .info-box h3 {
            color: #666;
            margin-bottom: 15px;
            font-size: 18px;
        }
        
        .info-item {
            display: flex;
            justify-content: space-between;
            padding: 10px 0;
            border-bottom: 1px solid #ddd;
        }
        
        .info-item:last-child {
            border-bottom: none;
        }
        
        .info-label {
            color: #666;
            font-weight: 500;
        }
        
        .info-value {
            color: #333;
            font-weight: bold;
        }
        
        .check-icon {
            color: #4caf50;
            font-size: 24px;
        }
        
        .cross-icon {
            color: #f44336;
            font-size: 24px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🔧 京东商城 - 浏览器缓存清理工具</h1>
        
        <div id="statusBox" class="status info">
            正在检查浏览器存储状态...
        </div>
        
        <div class="info-box">
            <h3>📊 当前存储信息</h3>
            <div class="info-item">
                <span class="info-label">Token:</span>
                <span id="tokenStatus" class="info-value">检查中...</span>
            </div>
            <div class="info-item">
                <span class="info-label">用户信息:</span>
                <span id="userStatus" class="info-value">检查中...</span>
            </div>
            <div class="info-item">
                <span class="info-label">购物车:</span>
                <span id="cartStatus" class="info-value">检查中...</span>
            </div>
            <div class="info-item">
                <span class="info-label">存储项总数:</span>
                <span id="totalItems" class="info-value">0</span>
            </div>
        </div>
        
        <button class="btn btn-primary" onclick="clearAllStorage()">
            🗑️ 清除所有缓存数据
        </button>
        
        <button class="btn btn-secondary" onclick="goToLogin()">
            🚀 前往登录页面
        </button>
    </div>

    <script>
        function checkStorage() {
            const token = localStorage.getItem('token');
            const userInfo = localStorage.getItem('userInfo');
            const cart = localStorage.getItem('cart');
            const totalItems = localStorage.length;
            
            document.getElementById('tokenStatus').innerHTML = token ? 
                '<span class="check-icon">✓</span> 已存储' : 
                '<span class="cross-icon">✗</span> 未存储';
            
            document.getElementById('userStatus').innerHTML = userInfo ? 
                '<span class="check-icon">✓</span> 已存储' : 
                '<span class="cross-icon">✗</span> 未存储';
            
            document.getElementById('cartStatus').innerHTML = cart ? 
                '<span class="check-icon">✓</span> 已存储' : 
                '<span class="cross-icon">✗</span> 未存储';
            
            document.getElementById('totalItems').textContent = totalItems;
            
            const statusBox = document.getElementById('statusBox');
            if (token) {
                statusBox.className = 'status warning';
                statusBox.innerHTML = '⚠️ 检测到旧的 Token，建议清除后重新登录';
            } else {
                statusBox.className = 'status success';
                statusBox.innerHTML = '✅ 本地存储已清空，可以重新登录';
            }
        }
        
        function clearAllStorage() {
            try {
                // 清除 localStorage
                localStorage.clear();
                
                // 清除 sessionStorage
                sessionStorage.clear();
                
                // 更新显示
                checkStorage();
                
                const statusBox = document.getElementById('statusBox');
                statusBox.className = 'status success';
                statusBox.innerHTML = '✅ 所有缓存数据已清除！可以重新登录了';
                
                // 3秒后自动跳转
                setTimeout(() => {
                    statusBox.innerHTML = '✅ 即将跳转到登录页面...';
                    setTimeout(() => {
                        goToLogin();
                    }, 1000);
                }, 2000);
                
            } catch (error) {
                const statusBox = document.getElementById('statusBox');
                statusBox.className = 'status warning';
                statusBox.innerHTML = '❌ 清除失败: ' + error.message;
            }
        }
        
        function goToLogin() {
            // 假设前端运行在 5173 端口
            window.location.href = 'http://localhost:5173';
        }
        
        // 页面加载时检查存储状态
        checkStorage();
    </script>
</body>
</html>











